package cn.stylefeng.guns.modular.user.service.impl;

import cn.stylefeng.guns.modular.user.mapper.WXUserMapper;
import cn.stylefeng.guns.modular.user.model.User;
import cn.stylefeng.guns.modular.user.service.IWXUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 杨煜
 * @Date: 2019/12/10 15:46
 * @Description:
 */
@Service
public class WXUserServiceImpl extends ServiceImpl<WXUserMapper, User> implements IWXUserService {
    @Override
    public User getByOpenId(String openId) {

        Map<String,Object> map = new HashMap<>();
        map.put("openid",openId);
        List<User> users = this.baseMapper.selectByMap(map);
        if(CollectionUtils.isEmpty(users)){
            return null;
        }
        return users.get(0);
    }
}
